<%--
  Created by IntelliJ IDEA.
  User: 薛之谦
  Date: 2025/9/18
  Time: 15:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="header.jsp"/>
<div>
    <table class="table mx-auto text-center">
        <thead>
        <tr>
            <th scope="col">试题ID</th>
            <th scope="col">题目</th>
            <th scope="col">选项</th>
            <th scope="col">答案</th>
            <th scope="col">试题类型</th>
            <th scope="col">课程</th>
            <th scope="col">启用状态</th>
        </tr>
        </thead>
        <tbody>
            <c:forEach items="${page.items}" var="examQuestion">
                <tr
                    <c:choose>
                        <c:when test="${roleId == 1}">
                            <c:if test="${user.id == 1 || user.id == 4}">
                                'disabled'
                            </c:if>
                        </c:when>
                        <c:when test="${roleId == 2 || roleId == 3}">
                            ''
                        </c:when>
                        <c:when test="${roleId == 4}">
                            <c:if test="${user.id == 1 || user.id == 4}">
                                'disabled'
                            </c:if>
                        </c:when>
                    </c:choose>>
                    <%-- 试题ID --%>
                    <td id="examQuestion">${examQuestion.id}</td>
                    <%-- 题目 --%>
                    <td>${examQuestion.title}</td>
                    <%-- 选项 --%>
                    <td>${examQuestion.option}</td>
                    <%-- 答案 --%>
                    <td>${examQuestion.answer}</td>
                    <td>
                        <c:choose>
                            <c:when test="${examQuestion.type == 1}">
                                单选题
                            </c:when>
                            <c:when test="${examQuestion.type == 2}">
                                多选题
                            </c:when>
                            <c:when test="${examQuestion.type == 3}">
                                判断题
                            </c:when>
                            <c:when test="${examQuestion.type == 4}">
                                填空题
                            </c:when>
                        </c:choose>
                    </td>
                    <td>${examQuestion.course}</td>
                    <td>
                        <div class="form-check form-switch" style="width: 50%;">
                            <input class="form-check-input start-info" type="checkbox" role="switch"
                                ${ user.state == true ? 'checked' : '' }>
                            <label class="form-check-label " for="start-info">启用</label>
                        </div>
                    </td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</div>
<jsp:include page="footer.jsp"/>